package com.glsc.ngateway.common.base.converter.platform;

import com.alibaba.excel.util.CollectionUtils;
import com.glsc.ngateway.common.api.flowable.dto.FlowFormMemoryOutDetailDto;
import com.glsc.ngateway.common.base.domain.mysql.gateway.platform.flow.cmdb.FlowFormMemoryOutDetail;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;

import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;

/**
 * @author xuchang
 */
public class FlowFormMemoryOutDetailConverter {

    public static FlowFormMemoryOutDetailDto do2Dto(FlowFormMemoryOutDetail domain) {
        if (Objects.isNull(domain)) {
            return null;
        }
        FlowFormMemoryOutDetailDto dto = FlowFormMemoryOutDetailMapper.INSTANCE.do2Dto(domain);
        return dto;
    }

    public static List<FlowFormMemoryOutDetailDto> do2Dto(List<FlowFormMemoryOutDetail> domainList) {
        return CollectionUtils.isEmpty(domainList) ? java.util.Collections.emptyList() : domainList.stream().map(FlowFormMemoryOutDetailConverter::do2Dto).collect(Collectors.toList());
    }

    public static FlowFormMemoryOutDetail dto2Do(FlowFormMemoryOutDetailDto dto) {
        if (Objects.isNull(dto)) {
            return null;
        }
        FlowFormMemoryOutDetail domain = FlowFormMemoryOutDetailMapper.INSTANCE.dto2Do(dto);
        return domain;
    }

    public static List<FlowFormMemoryOutDetail> dto2Do(List<FlowFormMemoryOutDetailDto> dtoList) {
        return CollectionUtils.isEmpty(dtoList) ? java.util.Collections.emptyList() : dtoList.stream().map(FlowFormMemoryOutDetailConverter::dto2Do).collect(Collectors.toList());
    }

    @Mapper(componentModel = "spring")
    public interface FlowFormMemoryOutDetailMapper {

        FlowFormMemoryOutDetailMapper INSTANCE = Mappers.getMapper(FlowFormMemoryOutDetailMapper.class);

        FlowFormMemoryOutDetailDto do2Dto(FlowFormMemoryOutDetail domain);

        List<FlowFormMemoryOutDetailDto> do2Dto(List<FlowFormMemoryOutDetail> domain);

        FlowFormMemoryOutDetail dto2Do(FlowFormMemoryOutDetailDto dto);

        List<FlowFormMemoryOutDetail> dto2Do(List<FlowFormMemoryOutDetailDto> dto);
    }
}
